package org.sunrise.game.http.main;

import org.sunrise.game.common.config.ConfigReader;
import org.sunrise.game.common.utils.Utils;
import org.sunrise.game.http.server.HttpServer;

import java.util.Properties;

public class HttpServerStartUp {
    public static void main(String[] args) {
        // args[0]:config path
        if (args.length == 0) {
            args = new String[] { "./config/http-config.properties" };
        }
        ConfigReader.loadConfig(args[0]);
        Properties properties = ConfigReader.getProp();
        if (properties == null) {
            return;
        }
        // 设置日志等级
        Utils.setLogLevel(properties.getProperty("log.level"));

        // 创建http服务
        var httpServer = new HttpServer(Integer.parseInt(properties.getProperty("http.port")));
        // 连接中心服
        httpServer.connectMaster();
        // 服务启动
        httpServer.start();
        // 内存检测
        Utils.startMemoryCheck();
    }
}
